package com.maoxs;

import com.maoxs.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

@Controller
@RequestMapping("/web")
public class FreeMarkerController {
    @RequestMapping("/index")
    public ModelAndView index() {
        ModelAndView mv = new ModelAndView("hello");
        //freemarker
        String name = "地下城小分队";
        List<User> users = new ArrayList<>();
        User user = null;
        for (int i = 1; i <= 10; i++) {
            user = new User(i + 0L, "勇士代号" + UUID.randomUUID().toString().substring(0, 6));
            users.add(user);
        }
        mv.addObject("name", name);
        mv.addObject("users", users);
        return mv;
    }
}
